package cn.zh.npro.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;

import cn.zh.npro.Item.OsItem;
import cn.zh.npro.R;

/**
 * Created by WYN on 2018/3/6 0006.
 */

public class OSAdapter extends BaseAdapter {

    Context context;
    ArrayList<OsItem> arrayList;
    LayoutInflater inflater;

    public OSAdapter(Context context, ArrayList<OsItem> arrayList){
        this.context=context;
        this.arrayList=arrayList;
        inflater=LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return arrayList.size();
    }

    @Override
    public Object getItem(int i) {
        return arrayList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
      }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        Holder holder=null;
        if (null==view){
            holder=new Holder();
            view=inflater.inflate(R.layout.os_layout,null,false);
            holder.scir=view.findViewById(R.id.scir);
            holder.vlin=view.findViewById(R.id.vlin);
            holder.stxt=view.findViewById(R.id.stxt);
            view.setTag(holder);
        }else {
            holder= (Holder) view.getTag();
            if ((arrayList.size()-1)==i){
                holder.vlin.setVisibility(View.GONE);
            }else {
                holder.vlin.setVisibility(View.VISIBLE);
            }

         }

        return view;
    }


    public class Holder{
        ImageView scir;
        View vlin;
        TextView stxt;
        }


}
